Skip to content

Commit bea11f0

Browse files
committed
Merge branch 'topic/firewire' into for-next
Pull FireWire fixes Signed-off-by: Takashi Iwai <[email protected]>
2 parents 81c254a + 39859be commit bea11f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+685
-343
lines changed

Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-rt5682s.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ properties:
1616
compatible:
1717
enum:
1818
- mediatek,mt8186-mt6366-rt1019-rt5682s-sound
19+
- mediatek,mt8186-mt6366-rt5682s-max98360-sound
1920

2021
mediatek,platform:
2122
$ref: "/schemas/types.yaml#/definitions/phandle"

Documentation/devicetree/bindings/sound/qcom,lpass-tx-macro.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ properties:
3030
const: 0
3131

3232
clocks:
33-
maxItems: 5
33+
oneOf:
34+
- maxItems: 3
35+
- maxItems: 5
3436

3537
clock-names:
3638
oneOf:

Documentation/devicetree/bindings/sound/qcom,lpass-wsa-macro.yaml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ title: LPASS(Low Power Audio Subsystem) VA Macro audio codec
99
maintainers:
1010
- Srinivas Kandagatla <[email protected]>
1111

12-
allOf:
13-
- $ref: dai-common.yaml#
14-
1512
properties:
1613
compatible:
1714
enum:
@@ -30,15 +27,12 @@ properties:
3027
const: 0
3128

3229
clocks:
33-
maxItems: 5
30+
minItems: 5
31+
maxItems: 6
3432

3533
clock-names:
36-
items:
37-
- const: mclk
38-
- const: npl
39-
- const: macro
40-
- const: dcodec
41-
- const: fsgen
34+
minItems: 5
35+
maxItems: 6
4236

4337
clock-output-names:
4438
maxItems: 1
@@ -55,10 +49,51 @@ required:
5549
- reg
5650
- "#sound-dai-cells"
5751

52+
allOf:
53+
- $ref: dai-common.yaml#
54+
55+
- if:
56+
properties:
57+
compatible:
58+
enum:
59+
- qcom,sc7280-lpass-wsa-macro
60+
- qcom,sm8450-lpass-wsa-macro
61+
- qcom,sc8280xp-lpass-wsa-macro
62+
then:
63+
properties:
64+
clocks:
65+
maxItems: 5
66+
clock-names:
67+
items:
68+
- const: mclk
69+
- const: npl
70+
- const: macro
71+
- const: dcodec
72+
- const: fsgen
73+
74+
- if:
75+
properties:
76+
compatible:
77+
enum:
78+
- qcom,sm8250-lpass-wsa-macro
79+
then:
80+
properties:
81+
clocks:
82+
minItems: 6
83+
clock-names:
84+
items:
85+
- const: mclk
86+
- const: npl
87+
- const: macro
88+
- const: dcodec
89+
- const: va
90+
- const: fsgen
91+
5892
unevaluatedProperties: false
5993

6094
examples:
6195
- |
96+
#include <dt-bindings/clock/qcom,sm8250-lpass-aoncc.h>
6297
#include <dt-bindings/sound/qcom,q6afe.h>
6398
codec@3240000 {
6499
compatible = "qcom,sm8250-lpass-wsa-macro";
@@ -69,7 +104,8 @@ examples:
69104
<&audiocc 0>,
70105
<&q6afecc LPASS_HW_MACRO_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>,
71106
<&q6afecc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>,
107+
<&aoncc LPASS_CDC_VA_MCLK>,
72108
<&vamacro>;
73-
clock-names = "mclk", "npl", "macro", "dcodec", "fsgen";
109+
clock-names = "mclk", "npl", "macro", "dcodec", "va", "fsgen";
74110
clock-output-names = "mclk";
75111
};

drivers/firewire/core-cdev.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct inbound_transaction_resource {
111111
struct client_resource resource;
112112
struct fw_card *card;
113113
struct fw_request *request;
114+
bool is_fcp;
114115
void *data;
115116
size_t length;
116117
};
@@ -643,19 +644,14 @@ static int ioctl_send_request(struct client *client, union ioctl_arg *arg)
643644
client->device->max_speed);
644645
}
645646

646-
static inline bool is_fcp_request(struct fw_request *request)
647-
{
648-
return request == NULL;
649-
}
650-
651647
static void release_request(struct client *client,
652648
struct client_resource *resource)
653649
{
654650
struct inbound_transaction_resource *r = container_of(resource,
655651
struct inbound_transaction_resource, resource);
656652

657-
if (is_fcp_request(r->request))
658-
kfree(r->data);
653+
if (r->is_fcp)
654+
fw_request_put(r->request);
659655
else
660656
fw_send_response(r->card, r->request, RCODE_CONFLICT_ERROR);
661657

@@ -669,37 +665,31 @@ static void handle_request(struct fw_card *card, struct fw_request *request,
669665
void *payload, size_t length, void *callback_data)
670666
{
671667
struct address_handler_resource *handler = callback_data;
668+
bool is_fcp = is_in_fcp_region(offset, length);
672669
struct inbound_transaction_resource *r;
673670
struct inbound_transaction_event *e;
674671
size_t event_size0;
675-
void *fcp_frame = NULL;
676672
int ret;
677673

678674
/* card may be different from handler->client->device->card */
679675
fw_card_get(card);
680676

677+
// Extend the lifetime of data for request so that its payload is safely accessible in
678+
// the process context for the client.
679+
if (is_fcp)
680+
fw_request_get(request);
681+
681682
r = kmalloc(sizeof(*r), GFP_ATOMIC);
682683
e = kmalloc(sizeof(*e), GFP_ATOMIC);
683684
if (r == NULL || e == NULL)
684685
goto failed;
685686

686687
r->card = card;
687688
r->request = request;
689+
r->is_fcp = is_fcp;
688690
r->data = payload;
689691
r->length = length;
690692

691-
if (is_fcp_request(request)) {
692-
/*
693-
* FIXME: Let core-transaction.c manage a
694-
* single reference-counted copy?
695-
*/
696-
fcp_frame = kmemdup(payload, length, GFP_ATOMIC);
697-
if (fcp_frame == NULL)
698-
goto failed;
699-
700-
r->data = fcp_frame;
701-
}
702-
703693
r->resource.release = release_request;
704694
ret = add_client_resource(handler->client, &r->resource, GFP_ATOMIC);
705695
if (ret < 0)
@@ -741,10 +731,11 @@ static void handle_request(struct fw_card *card, struct fw_request *request,
741731
failed:
742732
kfree(r);
743733
kfree(e);
744-
kfree(fcp_frame);
745734

746-
if (!is_fcp_request(request))
735+
if (!is_fcp)
747736
fw_send_response(card, request, RCODE_CONFLICT_ERROR);
737+
else
738+
fw_request_put(request);
748739

749740
fw_card_put(card);
750741
}
@@ -819,17 +810,19 @@ static int ioctl_send_response(struct client *client, union ioctl_arg *arg)
819810

820811
r = container_of(resource, struct inbound_transaction_resource,
821812
resource);
822-
if (is_fcp_request(r->request))
813+
if (r->is_fcp) {
814+
fw_request_put(r->request);
823815
goto out;
816+
}
824817

825818
if (a->length != fw_get_response_length(r->request)) {
826819
ret = -EINVAL;
827-
kfree(r->request);
820+
fw_request_put(r->request);
828821
goto out;
829822
}
830823
if (copy_from_user(r->data, u64_to_uptr(a->data), a->length)) {
831824
ret = -EFAULT;
832-
kfree(r->request);
825+
fw_request_put(r->request);
833826
goto out;
834827
}
835828
fw_send_response(r->card, r->request, a->rcode);

drivers/firewire/core-transaction.c

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,6 @@ const struct fw_address_region fw_unit_space_region =
535535
{ .start = 0xfffff0000900ULL, .end = 0x1000000000000ULL, };
536536
#endif /* 0 */
537537

538-
static bool is_in_fcp_region(u64 offset, size_t length)
539-
{
540-
return offset >= (CSR_REGISTER_BASE | CSR_FCP_COMMAND) &&
541-
offset + length <= (CSR_REGISTER_BASE | CSR_FCP_END);
542-
}
543-
544538
/**
545539
* fw_core_add_address_handler() - register for incoming requests
546540
* @handler: callback
@@ -617,6 +611,7 @@ void fw_core_remove_address_handler(struct fw_address_handler *handler)
617611
EXPORT_SYMBOL(fw_core_remove_address_handler);
618612

619613
struct fw_request {
614+
struct kref kref;
620615
struct fw_packet response;
621616
u32 request_header[4];
622617
int ack;
@@ -625,13 +620,33 @@ struct fw_request {
625620
u32 data[];
626621
};
627622

623+
void fw_request_get(struct fw_request *request)
624+
{
625+
kref_get(&request->kref);
626+
}
627+
628+
static void release_request(struct kref *kref)
629+
{
630+
struct fw_request *request = container_of(kref, struct fw_request, kref);
631+
632+
kfree(request);
633+
}
634+
635+
void fw_request_put(struct fw_request *request)
636+
{
637+
kref_put(&request->kref, release_request);
638+
}
639+
628640
static void free_response_callback(struct fw_packet *packet,
629641
struct fw_card *card, int status)
630642
{
631-
struct fw_request *request;
643+
struct fw_request *request = container_of(packet, struct fw_request, response);
632644

633-
request = container_of(packet, struct fw_request, response);
634-
kfree(request);
645+
// Decrease the reference count since not at in-flight.
646+
fw_request_put(request);
647+
648+
// Decrease the reference count to release the object.
649+
fw_request_put(request);
635650
}
636651

637652
int fw_get_response_length(struct fw_request *r)
@@ -782,6 +797,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
782797
request = kmalloc(sizeof(*request) + length, GFP_ATOMIC);
783798
if (request == NULL)
784799
return NULL;
800+
kref_init(&request->kref);
785801

786802
request->response.speed = p->speed;
787803
request->response.timestamp =
@@ -800,16 +816,22 @@ static struct fw_request *allocate_request(struct fw_card *card,
800816
return request;
801817
}
802818

819+
/**
820+
* fw_send_response: - send response packet for asynchronous transaction.
821+
* @card: interface to send the response at.
822+
* @request: firewire request data for the transaction.
823+
* @rcode: response code to send.
824+
*
825+
* Submit a response packet into the asynchronous response transmission queue. The @request
826+
* is going to be released when the transmission successfully finishes later.
827+
*/
803828
void fw_send_response(struct fw_card *card,
804829
struct fw_request *request, int rcode)
805830
{
806-
if (WARN_ONCE(!request, "invalid for FCP address handlers"))
807-
return;
808-
809831
/* unified transaction or broadcast transaction: don't respond */
810832
if (request->ack != ACK_PENDING ||
811833
HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) {
812-
kfree(request);
834+
fw_request_put(request);
813835
return;
814836
}
815837

@@ -821,6 +843,9 @@ void fw_send_response(struct fw_card *card,
821843
fw_fill_response(&request->response, request->request_header,
822844
rcode, NULL, 0);
823845

846+
// Increase the reference count so that the object is kept during in-flight.
847+
fw_request_get(request);
848+
824849
card->driver->send_response(card, &request->response);
825850
}
826851
EXPORT_SYMBOL(fw_send_response);
@@ -910,7 +935,7 @@ static void handle_fcp_region_request(struct fw_card *card,
910935
rcu_read_lock();
911936
list_for_each_entry_rcu(handler, &address_handler_list, link) {
912937
if (is_enclosing_handler(handler, offset, request->length))
913-
handler->address_callback(card, NULL, tcode,
938+
handler->address_callback(card, request, tcode,
914939
destination, source,
915940
p->generation, offset,
916941
request->data,

drivers/firewire/core.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ int fw_get_response_length(struct fw_request *request);
244244
void fw_fill_response(struct fw_packet *response, u32 *request_header,
245245
int rcode, void *payload, size_t length);
246246

247+
void fw_request_get(struct fw_request *request);
248+
void fw_request_put(struct fw_request *request);
249+
247250
#define FW_PHY_CONFIG_NO_NODE_ID -1
248251
#define FW_PHY_CONFIG_CURRENT_GAP_COUNT -1
249252
void fw_send_phy_config(struct fw_card *card,
@@ -254,4 +257,10 @@ static inline bool is_ping_packet(u32 *data)
254257
return (data[0] & 0xc0ffffff) == 0 && ~data[0] == data[1];
255258
}
256259

260+
static inline bool is_in_fcp_region(u64 offset, size_t length)
261+
{
262+
return offset >= (CSR_REGISTER_BASE | CSR_FCP_COMMAND) &&
263+
offset + length <= (CSR_REGISTER_BASE | CSR_FCP_END);
264+
}
265+
257266
#endif /* _FIREWIRE_CORE_H */

drivers/spi/spi-mt65xx.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,11 @@ static int mtk_spi_probe(struct platform_device *pdev)
12531253
dev_notice(dev, "SPI dma_set_mask(%d) failed, ret:%d\n",
12541254
addr_bits, ret);
12551255

1256+
ret = devm_request_irq(dev, irq, mtk_spi_interrupt,
1257+
IRQF_TRIGGER_NONE, dev_name(dev), master);
1258+
if (ret)
1259+
return dev_err_probe(dev, ret, "failed to register irq\n");
1260+
12561261
pm_runtime_enable(dev);
12571262

12581263
ret = devm_spi_register_master(dev, master);
@@ -1261,13 +1266,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
12611266
return dev_err_probe(dev, ret, "failed to register master\n");
12621267
}
12631268

1264-
ret = devm_request_irq(dev, irq, mtk_spi_interrupt,
1265-
IRQF_TRIGGER_NONE, dev_name(dev), master);
1266-
if (ret) {
1267-
pm_runtime_disable(dev);
1268-
return dev_err_probe(dev, ret, "failed to register irq\n");
1269-
}
1270-
12711269
return 0;
12721270
}
12731271

include/linux/firewire.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,8 @@ typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
278278
* Otherwise there is a danger of recursion of inbound and outbound
279279
* transactions from and to the local node.
280280
*
281-
* The callback is responsible that either fw_send_response() or kfree()
282-
* is called on the @request, except for FCP registers for which the core
283-
* takes care of that.
281+
* The callback is responsible that fw_send_response() is called on the @request, except for FCP
282+
* registers for which the core takes care of that.
284283
*/
285284
typedef void (*fw_address_callback_t)(struct fw_card *card,
286285
struct fw_request *request,

0 commit comments

Comments
 (0)